package com.cn.sl.server.common.enumerate

import com.fasterxml.jackson.annotation.JsonCreator

/**
 * 性别
 *
 * @author 阮雪峰
 */
enum class Gender(val value: String) {
    /**
     * 男
     */
    MALE("男"),

    /**
     * 女
     */
    FEMALE("女");

    companion object {
        @JsonCreator
        fun create(code: String): Gender? {
            for (item in entries) {
                if (item.toString() == code) {
                    return item
                }
            }
            return null
        }

        fun nameToVal(name: String?): Gender? {
            if (name == null) {
                return null
            } else {
                for (item in entries) {
                    if (item.name == name) {
                        return item
                    }
                }
                return null
            }
        }
    }
}